package com.xzr.entity;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @Author：jojo
 * @Date：2022/2/10 17:06
 * @Description :TODO
 */
public class User {
    @NotEmpty(message = "名字不能为空")
    @Length(min = 1,max = 10,message = "名字不能超过10个字符")
    private String name;
    @NotBlank(message = "电话不能为空")
    @Pattern(regexp = "^134[0-8]\\d{7}$|^13[^4]\\d{8}$|^14[5-9]\\d{8}$|^15[^4]\\d{8}$|^16[6]\\d{8}$|^17[0-8]\\d{8}$|^18[\\d]{9}$|^19[8,9]\\d{8}$",message = "电话格式不正确")
    private String telphone;
    @Email(message = "邮箱格式不正确")
    private String email;

    @Valid
    @NotNull(message = "不能没")
    private Gril gril;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTelphone() {
        return telphone;
    }

    public void setTelphone(String telphone) {
        this.telphone = telphone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Gril getGril() {
        return gril;
    }

    public void setGril(Gril gril) {
        this.gril = gril;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", telphone='" + telphone + '\'' +
                ", email='" + email + '\'' +
                ", gril=" + gril +
                '}';
    }
}
